var AddSummary = {};
AddSummary.contextpath = "";
AddSummary.initPage = function(contextpath) {
	AddSummary.contextpath = contextpath;

	layui.use(['form', 'layedit', 'laydate'], function(){
		  var form = layui.form
		  ,layer = layui.layer
		  ,layedit = layui.layedit
		  ,laydate = layui.laydate;
		  
		  //日期
		  laydate.render({
		    elem: '#date'
		  });
		  //创建一个编辑器
		  var editIndex = layedit.build('LAY_demo_editor');
		 		  
		  //监听提交
		  form.on('submit(submit)', function(data){
//		    layer.alert(JSON.stringify(data.field), {
//		      title: '最终的提交信息'
//		    })
			  AddSummary.ajaxSaveSummary(data);
		    return false;
		  });
		});
}


AddSummary.ajaxSaveSummary = function(data1) {
	$.ajax({
		type : "POST",
		url : "/web2019/user/ajaxSaveSummary.action",
		dataType : "json",
		data : data1.field,
		beforeSend:function(){
			layer.load(1);
		},
		complete:function(){
			layer.close(layer.index-1);
		},
		success : function(data) {
			if (data.code == "0000") {
				layer.alert(data.message, { icon: 1, closeBtn: 0 }, function (index) { 
					layer.close(index);
					window.location.href="/web2019/user/addSummary.action";
				});
			} else {
				layer.alert(data.message);
			}
		},
		error : function(data) {

		}
	});
}
